<%@ page import="java.text.SimpleDateFormat" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: 波哥
  Date: 2018/3/7
  Time: 10:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <base href="<%=request.getContextPath()%>/"/>

    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="common/bootstrap/css/bootstrap.css" media="all">
    <link rel="stylesheet" type="text/css" href="common/global.css" media="all">
    <link rel="stylesheet" type="text/css" href="css/personal.css" media="all">

</head>
<body>

<section class="layui-larry-box">
    <div class="larry-personal">
        <div class="layui-tab">
            <blockquote cla ss="layui-elem-quote news_search">
                日志级别：
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <%--<input value="" placeholder="请输入关键字" class="layui-input search_input" type="text">--%>
                        <select>

                            <option>一般信息</option>
                            <option>错误信息</option>
                        </select>
                    </div>
                    <a  href="system_log/findByType">查询</a>
                    日志时间:
                    <input type="date">
                    <input type="date">
                </div>
                <%--<div class="layui-inline">--%>
                <%--<a class="layui-btn layui-btn-normal newsAdd_btn">添加文章</a>--%>
            <%--</div>--%>
                <%--<div class="layui-inline">--%>
                    <%--<a class="layui-btn recommend" style="background-color:#5FB878">推荐文章</a>--%>
                <%--</div>--%>
                <%--<div class="layui-inline">--%>
                    <%--<a class="layui-btn audit_btn">审核文章</a>--%>
                <%--</div>--%>
                <div class="layui-inline">
                    <%--<a class="layui-btn layui-btn-danger batchDel" id="batchdelete">批量删除</a>--%>
                </div>

            </blockquote>

            <!-- 操作日志 -->
            <div class="layui-form news_list">
                <table class="layui-table">
                    <tr><a  id="bathdel" class="layui-btn layui-btn-danger ">批量删除</a> </tr>
                    <colgroup>
                        <col width="50">
                        <col>
                        <col width="9%">
                        <col width="9%">
                        <col width="9%">
                        <col width="9%">
                        <col width="9%">
                        <col width="15%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th width="100"><input name="" lay-skin="primary" lay-filter="allChoose" id="allChoose" type="checkbox">
                            <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i class="layui-icon"></i></div>
                        </th>
                        <th style="text-align:left; width: 150px">日志时间</th>
                        <th width="200">日志级别</th>
                        <th width="300">描述</th>
                    </tr>
                    </thead>

                         <tbody class="news_content">
                         <c:forEach items="${system_logs}" var="log">
                        <tr>
                             <td><input name="checked" lay-skin="primary" value="${log.logId}" lay-filter="choose" type="checkbox">
                                <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i class="layui-icon"></i></div>
                            </td>
                            <td align="left"><fmt:formatDate type="BOTH"
                                                             value="${log.logDate}" /></td>
                            <td>${log.logTypeString}</td>
                            <td>IP为${log.logIp}的用户${log.logUser}已经成功${log.logStateString}</td>
                        </tr>
                         </c:forEach>
                        </tbody>

                </table>
                <div class="larry-table-page clearfix">
                    <a type="button" class="btn btn-warning" href='system_log/createExcel' id='export'>导出</a>
                    <form action="system_log/uploadExcel" method="post" enctype="multipart/form-data" >
                        <input type="file" name = "file">
                        <input type="submit" >
                    </form>
                <%--<a href="javascript:;" class="layui-btn layui-btn-small"><i class="iconfont icon-shanchu1"></i>删除</a>--%>
                    <div id="page" class="page"></div>
                </div>
            </div>
            <!-- 登录日志 -->
            <div class="layui-tab-item layui-field-box">
                <table class="layui-table table-hover" lay-even="" lay-skin="nob">
                    <thead>
                    <tr>
                        <th><input type="checkbox" id="selected-all"></th>
                        <th>ID</th>
                        <th>管理员账号</th>
                        <th>状态</th>
                        <th>最后登录时间</th>
                        <th>上次登录IP</th>
                        <th>登录IP</th>
                        <th>IP所在位置</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td><input type="checkbox"></td>
                        <td>110</td>
                        <td>admin</td>
                        <td>后台登录成功</td>
                        <td>2016-12-19 14:26:03</td>
                        <td>127.0.0.1</td>
                        <td>127.0.0.1</td>
                        <td>Unknown</td>
                    </tr>
                    </tbody>
                </table>
                <a href='system_log/createExcel'>导出</a>
                <div class="larry-table-page clearfix">

                    <%--<a href="javascript:;" class="layui-btn layui-btn-small"><i class="iconfont icon-shanchu1"></i>删除</a>--%>
                    <div id="page2" class="page"></div>
                </div>
            </div>
        </div>
    </div>

</section>
<script type="text/javascript" src="common/layui/layui.js"></script>
<script type="text/javascript" src="js/newslist.js"></script>
<script type="text/javascript" src="js/jquery-2.1.0.js"></script>
<script type="text/javascript">
    $(function () {
        $("#bathdel").click(function () {

            var arr = document.getElementsByName("checked");
            var qqq = "";
            for (i =0;i<arr.length;i++){
                if(arr[i].checked){
                 //   alert(arr[i].value);
                    qqq+=arr[i].value+",";
                }
            }
            qqq=qqq.substr(0, qqq.length - 1);

//            $.get({
//                url:"system_log/delete",
//                data:arr,
//                success:function () {
//                    alert("删除成功")
//                }
//            })

            var $checkbox = $('.news_list tbody input[type="checkbox"][name="checked"]');
            var $checked = $('.news_list tbody input[type="checkbox"][name="checked"]:checked');

            if($checkbox.is(":checked")){
                layer.confirm('确定删除选中的信息？',{icon:3, title:'提示信息'},function(index){
                    var index = layer.msg('删除中，请稍候',{icon: 16,time:false,shade:0.8});
                    setTimeout(function(){
                        //删除数据
                        $.ajax({
                            url:"system_log/delete",    //请求的url地址

                            async:true,//请求是否异步，默认为异步，这也是ajax重要特性
                            data:{"id":qqq},    //参数值
                            type:"GET",   //请求方式

                            success:function(req){
                                //window.location.reload();
                                //location.href = url + "/system_log/delete";
                                //请求成功时处理
                                // alert("删除成功")
//                                $('.news_list thead input[type="checkbox"]').prop("checked",false);
//                                form.render();
//                                layer.close(index);
                                //layer.msg("删除成功");
                                layer.alert("删除成功",{
                                         skin: 'layui-layer-molv' //样式类名  自定义样式
                                     ,closeBtn: 1    // 是否显示关闭按钮
                                     ,anim: 1 //动画类型
                                     ,btn: ['确定'] //按钮
                                     ,icon: 11   // icon
                                     ,yes:function(){
                                             //layer.msg('按钮1')
                                        window.location.reload();
                                         }
                                     });
                                //window.location.reload();
                            }

                        });


                    },2000);
                })
            }else{
                layer.msg("请选择需要删除的文章");
            }


        })
    })
    layui.use(['jquery','layer','element','laypage'],function(){
        window.jQuery = window.$ = layui.jquery;
        window.layer = layui.layer;
        var element = layui.element(),
            laypage = layui.laypage;


        laypage({
            cont: 'page',
            pages: 10 //总页数
            ,
            groups: 5 //连续显示分页数
            ,
            jump: function(obj, first) {
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                if(!first) {
                    //layer.msg('第 '+ obj.curr +' 页');
                }
            }
        });

        laypage({
            cont: 'page2',
            pages: 10 //总页数
            ,
            groups: 5 //连续显示分页数
            ,
            jump: function(obj, first) {
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                if(!first) {
                    //layer.msg('第 '+ obj.curr +' 页');
                }
            }
        });
    });
</script>
</body>
</html>
